package com.kim.logs.core.provider;

import com.kim.logs.bean.OperatorLog;
import com.kim.logs.utils.ProduceSql;
import org.springframework.jdbc.core.JdbcTemplate;

import javax.sql.DataSource;

public class JDBCLogAppendeServiceManager implements LogAppenderService {

    private static final String TABLE = "kim_operator_logs";
    private JdbcTemplate jdbcTemplate;
    private String sysCode;

    public JDBCLogAppendeServiceManager(JdbcTemplate jdbcTemplate, String sysCode) {
        super();
        this.jdbcTemplate = jdbcTemplate;
        this.sysCode = sysCode;
    }

    public JDBCLogAppendeServiceManager(DataSource dataSource) {
        super();
        this.jdbcTemplate = new JdbcTemplate(dataSource);
    }

    @Override
    public void append(OperatorLog operatorLog) throws RuntimeException {
        jdbcTemplate.execute(ProduceSql.getInsertSql("kim_operator_logs", operatorLog));
    }

}
